package com.example.day2.exercise;

import java.io.File;
import java.util.List;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

public class Exercise4 {

    record Student(String name) {
    }

    // 写出与下列 lambda 表达式 等价的方法引用
    public static void main(String[] args) {
        Function<String, Integer> lambda1 = s -> Integer.parseInt(s);

        lambda1 = Integer::parseInt;

        BiPredicate<List<String>, String> lambda2 = (list, element) -> list.contains(element);

        lambda2 = List::contains;

        BiPredicate<Student, Object> lambda3 = (stu, obj) -> stu.equals(obj);

        lambda3 = Student::equals;

        Predicate<File> lambda4 = (file) -> file.exists();
        lambda4 = File::exists;

        Runtime runtime = Runtime.getRuntime();

        Supplier<Long> lambda5 = () -> runtime.freeMemory();

        lambda5 = runtime::freeMemory;
    }
}
